﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<IEnumerable<SDT.Model.Menu>>" %>
<div id="nav">
	<ul>
    	<%string cClass = "act";
        var cUrl = Request.Url.PathAndQuery.ToLower();
        if (cUrl == "/") cUrl = "/home";   
        var index = 0;
      foreach( var m in Model){
          var current = cUrl == m.NavigateUrl.Trim().ToLower() ? cClass : string.Empty;
          index += 1;

          var enda = index == Model.ToList().Count ? "none" : string.Empty;
          var childs = m.ChildMenus.Where(e => e.PubYN == true).ToList();
          if(current==string.Empty)
          foreach (var child in childs) {
              if (cUrl == child.NavigateUrl.Trim().ToLower()) {
                  current = cClass;
              }
          }
          var style = current != string.Empty ? "block" : string.Empty;
          %>
        <li><a class="<%=current +" "+enda %>" href="<%=m.NavigateUrl %>"><%=Html.Encode(m.Name) %></a>
            <%
              if (childs.Count > 0)
              { %>
              <ul class="children" style="display:<%=style%>">
                <%foreach (var c in m.ChildMenus)
                  {
                      if (c.PubYN == true)
                      {
                          var childcurrent = cUrl == c.NavigateUrl ? cClass : string.Empty;
                      %>
                  <li><a class="<%=childcurrent%>" href="<%=c.NavigateUrl %>"><%=Html.Encode(c.Name)%></a></li>
                <%}
                  } %>
              </ul>
          <%} %>
        </li>
      <%} %> 
    </ul>
</div>
<div class="bg_nav_bottom"></div>
